<template>
  <div class="app-main max">
    <el-menu :default-active="defaultActive" @select="handleMenuSelect">
      <template v-for="route in defaultRoutes">
        <el-menu-item v-if="route.menu" :key="route.path" :index="route.path">
          <span>{{route.name}}</span>
        </el-menu-item>
      </template>
    </el-menu>
    <div class="content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>

import {defaultRoutes} from '@/route';

export default {
  name: 'App',
  data(){
    return{
      defaultRoutes,
      defaultActive: null
    };
  },
  watch: {
    '$route.path'(val){
      this.defaultActive = val;
    }
  },
  methods: {
    handleMenuSelect(index){
      this.$router.push(index);
    }
  }
};
</script>

<style lang="less" scoped>
.app-main {
  display: flex;

  .el-menu{
    width: 300px;
  }
  .content{
    width: 100%;
    padding: 10px;
  }
}
</style>
